/*
 * 冷梓硕
 *
 * */
package com.example.demo.controller;

import com.example.demo.model.Liabilities;
import com.example.demo.tool.ResponseMessage;
import com.example.demo.tool.Result;
import com.example.demo.service.LiabilitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController("/Liabilities")

public class LiabilitiesController {
    @Autowired
    private LiabilitiesService liabilitiesService;

    @CrossOrigin
    @RequestMapping(value = "/getLiaStr")
    public String getLiaStr(String liastr){
        return "你输入的名字叫" +liastr;
    }

    @CrossOrigin
    @RequestMapping(value = "/getLiaOne")
    public Liabilities getLiaOne(int lid){
        return liabilitiesService.LiaselectByPrimaryKey(lid);
    }

    @CrossOrigin
    @RequestMapping(value = "/getAssets")
    public List<Liabilities> getAssets(){
        System.out.println("调用角色全部类型的接口");
        List<Liabilities> listLiabilities = liabilitiesService.getAssets();
        return listLiabilities;
    }

    @CrossOrigin
    @RequestMapping(value = "/getLiaAll")
    public ResponseMessage getLiaAll(){
        System.out.println("调用角色全部信息的方法");
        Map<String,List> map=new HashMap<>();
        List<Liabilities> liabilitiess=liabilitiesService.getLiaAll();
        map.put("list",liabilitiess);
        return Result.success("200",map);
    }

    @CrossOrigin
    @RequestMapping(value = "/delLiabilities",method = RequestMethod.GET)
    public int delLiabilities(int lid){
        return liabilitiesService.delLiabilities(lid);
    }

    @CrossOrigin
    @RequestMapping(value = "/addLiabilities",method = RequestMethod.PUT)
    public int addLiabilities(@RequestBody Liabilities liabilitiesmodel){
        if (liabilitiesmodel!=null){}else {}
        return liabilitiesService.insertLiabilities(liabilitiesmodel);
    }


    @CrossOrigin
    @RequestMapping(value = "/editLiabilities",method = RequestMethod.PUT)
    public int editLiabilities(@RequestBody Liabilities liabilitiesmodel){
        if (liabilitiesmodel!=null){}else {}
        return liabilitiesService.editLiabilities(liabilitiesmodel);
    }


}
